package leetcode;

import javax.swing.tree.TreeNode;

/**
 * 二叉搜索树中的搜索
 */
public class Solution18 {
    public TreeNode searchBST(TreeNode root, int val) {
        //*
        if(root == null || root.val == val){
            return root;
        }//



        TreeNode result = null;
        if(val > root.val){
            result = searchBST(root.right,val);
        }
        if(val < root.val){
            result = searchBST(root.left,val);
        }

        return result;
    }
}
